package com.bryantkobe.myspringcode.service.impl;

import com.bryantkobe.myspringcode.entity.ServerLog;
import com.bryantkobe.myspringcode.mapper.ServerLogMapper;
import com.bryantkobe.myspringcode.service.IServerlogService;
import com.github.f4b6a3.ulid.Ulid;
import com.github.f4b6a3.ulid.UlidCreator;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @description: 日志服务实现类
 * @author: alienwarezzl
 * @date: 2025/9/14
 */
@Service
public class IServerlogServiceImpl implements IServerlogService {

    @Resource
    private ServerLogMapper serverLogMapper;

    @Override
    public void savekeepalivedMessage(String message) {
        ServerLog serverLog = new ServerLog();

        Ulid monotonicUlid = UlidCreator.getMonotonicUlid();
        serverLog.setId(monotonicUlid.toString());

        serverLog.setMessage(message);
        serverLog.setLevel(5);
        serverLog.setPosttime(LocalDateTime.now());

        serverLogMapper.insert(serverLog);
    }
}
